<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    const data = {
      a: 10,
      b: 20
    }
    const proxyData = new Proxy(data, {
      // 取值时候触发 劫持 拿到的值 时 return 的值
      get(target, key) {
        console.log('getter触发');
        return target[key]
      },
      // 劫持目标对象任意属性 取值的操作
      set(target, key, val){
        console.log('setter触发');
        target[key] = val;
      }
    })
    console.log(proxyData.a);
    proxyData.a = 200
    console.log(proxyData.a);
  </script>
</body>
</html>